package cz.boxdesign.library.web.validation;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import cz.boxdesign.library.entity.Publisher;

public class PublisherValidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return clazz == Publisher.class;
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nazev", "error.field.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ulice", "error.field.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mesto", "error.field.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "psc", "error.field.required");
	}

}
